package com.example.cardserver.controller;

import com.example.cardserver.entity.SocNews;
import com.example.cardserver.service.ISocNewsService;
import com.example.cardserver.util.JsonResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RequestMapping("socnews")
@RestController
public class SocNewsController extends BaseController{
    @Resource
    private ISocNewsService socNewsService;
    
    @RequestMapping("news")
    public JsonResult<List<SocNews>> getList(){
        List<SocNews> data = socNewsService.listAllNews();
        return new JsonResult<List<SocNews>>(OK, data);
    }
    
    @RequestMapping(value = "/newsbyid", method = RequestMethod.POST)
    public JsonResult<SocNews> findNewsById(Integer id){
        SocNews data = socNewsService.findById(id);
        return new JsonResult<>(OK, data);
    }
}
